#ifndef __HC_H
#define __HC_H

#define PWM_TOP_VALUE			20000

#define RUDDER_CENTER_POS		1400
#define RUDDER_MAX_LEFT_POS		700
#define RUDDER_MAX_RIGHT_POS	2100

#define MIN_THRUST_POWER		0
#define MAX_THRUST_POWER		PWM_TOP_VALUE

#define GET_RUDDER_POS()		(OCR1B)
#define SET_RUDDER_POS(_POS)	(OCR1B = _POS)

#define TURN_LIFT_ON()			(PORTB |= _BV(PB0))
#define TURN_LIFT_OFF()			(PORTB &= ~_BV(PB0))
#define IS_LIFT_ON()			((PORTB & _BV(PB0)) != 0)

#define GET_THRUST_POWER()		(OCR1A)
#define SET_THRUST_POWER(_THR)	(OCR1A = _THR)


#define LIFT_BIT				(1<<0)
#define TRCTL_BIT				(1<<1)
#define THRUST_BIT0				(1<<2)
#define THRUST_BIT1				(1<<3)
#define TURN_BIT0				(1<<4)
#define TURN_BIT1				(1<<5)
#define TURN_BIT2				(1<<6)
#define TURN_DIRECTION_BIT		(1<<7)
#define TURNING_BITS			(TURN_BIT0 | TURN_BIT1 | TURN_BIT2 | TURN_DIRECTION_BIT)

#define THRUST_SPEED_1			67
#define THRUST_SPEED_2			133
#define THRUST_SPEED_3			THRUST_SPEED_1+THRUST_SPEED_3


#define TURNING_RUDDER_POS_1	234
#define TURNING_RUDDER_POS_2	466
#define TURNING_RUDDER_POS_3	TURNING_RUDDER_POS_1+TURNING_RUDDER_POS_2

#define MAX_RUDDER_ANGLE		60
#define RUDDER_MOVING_STEP_INTERVAL		10

#define RUDDER_POS_TO_DEGREE_RATIO	((float) ((RUDDER_MAX_RIGHT_POS-RUDDER_CENTER_POS)/MAX_RUDDER_ANGLE))


volatile inline int8_t getRudderAngle();

#endif